<template>
  <view>
    <view class="treatment-title fontsize14">
      请描述你的疾病或症状、是否用药，需要提供什么样的帮助。
      <span class="color3FA" @click="showDesc">如何描述</span>?
    </view>
    <view class="main">
      <view class="color999 fontsize14">本平台为您保障隐私，内容仅医生可见</view>
      <view class="line"></view>
      <view>
        <view>病情描述</view>
        <view>
          <input type="text" v-model="Diseasequery.depict" placeholder="请输入" />
        </view>
      </view>
      <view>
        <view>患病时长</view>
        <view>
          <input type="text" v-model="Diseasequery.duration" placeholder="请输入" />
        </view>
      </view>
      <view>
        <view>医院检查</view>
        <view>
          <input type="text" v-model="Diseasequery.examine" placeholder="请输入" />
        </view>
      </view>
      <view>
        <view>用药情况</view>
        <view>
          <input type="text" v-model="Diseasequery.medication" placeholder="请输入" />
        </view>
      </view>
    </view>
    <view class="maintwo fontsize14">
      <view class="color333">上传照片/视频</view>
      <view class="color999 mainpng">上传病症照片、医院检查结果等，上传的内容仅对医生可见</view>
      <view>
        <MyUpload @uploadarr="uploadarr" @delarr="delarr" ref="upload"></MyUpload>
      </view>
    </view>
    <view class="treatbtn">
      <my-button borderRadius="8" height="96" hoverClass="none" width="670" @click="todeit">
        确认修改
      </my-button>
    </view>
    <view v-if="descshow" @click="hidedesc" class="Desccon">
      <image src="https://applet.youtuyiliao.com/profile/upload/xiaochengxu/static/decs.png" mode=""></image>
    </view>
  </view>
</template>

<script>
import MyUpload from "../../../component/My-upload.vue"
import { updateDiseaseOrder, getDiseaseOrderDetils } from '../../../api/index.js'
import MyButton from "@/chronicDisease/components/my-button/my-button.vue";
export default {
  components: {
    MyUpload,
    MyButton
  },
  data() {
    return {
      descshow: false,
      pic_arr: [],
      content: '目前平台上门医生只负责慢性病疮口的治疗，您确定需要医生上门吗？',
      title: '',
      traeteshow: false,
      Diseasequery: {
        orderNumber: '',//	必选	String	订单号
        depict: '',//	必选	String	描述
        duration: '',//	必选	String	时长
        examine: '',//	必选	String	医院检查
        medication: '',//	必选	String	用药情况
        imageUrls: '',//	必选	String	图片内容多个以逗号拼接
      }
    }
  },
  onLoad(options) {
	orderNumber: this.Diseasequery.orderNumber=options.orderNumber
    if (!uni.getStorageSync('token')) {
      uni.reLaunch({
        url: '../login/login'
      })
      return
    }
    // if (options.orderNumber!=null) {
		console.log('进来了')
      this.Diseasequery.orderNumber = options.orderNumber
      this._getDiseaseOrderDetils()
    // }
  },
  methods: {
    showDesc() {
      this.descshow = true
    },
    hidedesc() {
      this.descshow = false
    },
    _getDiseaseOrderDetils() {
      getDiseaseOrderDetils({
        orderNumber: this.Diseasequery.orderNumber
      }).then(res => {
        console.log(res.data)
        this.Diseasequery = res.data
        if (this.Diseasequery.imageUrls) {
          this.Diseasequery.imageUrls = this.Diseasequery.imageUrls.split(',')
          this.$refs.upload.pic_arr = this.Diseasequery.imageUrls
        }
      })
    },
    uploadarr(arr) {
      // this.Diseasequery.imageUrls=arr.join(',')
      this.Diseasequery.imageUrls = arr
      console.log('arr', this.Diseasequery.imageUrls)
    },
    delarr(arr) {
      console.log('del1', arr)
      // this.Diseasequery.imageUrls=arr.join(',')
    },

    //确认修改
    todeit() {
      console.log(this.Diseasequery.imageUrls)
      if (this.Diseasequery.imageUrls) {
        this.Diseasequery.imageUrls = this.Diseasequery.imageUrls.join(",")
      }
      if (!this.Diseasequery.depict && !this.Diseasequery.duration && !this.Diseasequery.examine && !this.Diseasequery.medication && !this.Diseasequery.imageUrls) {
        this.$toast('请完善信息')
        return;
      }
      updateDiseaseOrder(this.Diseasequery).then(res => {
        if (res.code == 200) {
          uni.navigateTo({
            url: '../editsuccess/editsuccess'
          })
        }
      })

    }
  }
}
</script>

<style lang="scss">
.treatment-title {
  background-color: #f7f7f7;
  padding: 24rpx 68rpx;
}

.main {
  padding: 0 40rpx;
  display: flex;
  flex-direction: column;
  justify-content: center;

  .line {
    height: 18rpx;
    background-color: #f7f7f7;
  }

  >view {
    height: 108rpx;
    margin: auto 0;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    font-size: 28rpx;
    border-bottom: 2rpx solid #f7f7f7;

    input {
      text-align: right;
      font-size: 28rpx;
    }
  }
}

.maintwo {
  padding: 32rpx 40rpx 58rpx 40rpx;

  .mainpng {
    margin: 20rpx 0;
  }
}

.treatbtn {
  padding: 0 40rpx 72rpx 40rpx;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  font-size: 28rpx;
}

.Desccon {
  position: fixed;
  top: 0;
  background: rgba(0, 0, 0, 0.6);
  width: 100vw;
  height: 100vh;
  z-index: 100;
}

.Desccon image {
  width: 100vw;
  height: 1100rpx;
}
</style>
